/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bdd.beans;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import bdd.DBLink;
import java.sql.Date;

/**
 *
 * @author maboisba
 */
public class ListeEC {

  //private DBLink dblink;
  List<Ec> listeEC;

  public ListeEC() {
      //dblink = new DBLink();
    listeEC = new ArrayList<Ec>();
  }

  public ListeEC(List<Ec> listeEC) {
     // dblink = new DBLink();
    this.listeEC = listeEC;
  }

  public List<Ec> getListeEC() {
    return listeEC;
  }

  public void setListeEC(List<Ec> listeEC) {
    this.listeEC = listeEC;
  }

  public void add(Ec ec) {
    listeEC.add(ec);
  }

  public void recupererListeEC(){
        int numEC;
        String libelleEC;
        try {
            
            DBLink db = new DBLink();
            db.connexion();
            PreparedStatement pst = db.getConnection().prepareStatement("SELECT * FROM EC");
            db.setPst(pst);
            ResultSet rs = db.getPst().executeQuery();
            db.setRs(rs);
            while(db.getRs().next()){
                numEC = db.getRs().getInt("numec");
                libelleEC = db.getRs().getString("libelle");
                Ec ec = new Ec();
                ec.setNumec(numEC);
                ec.setLibelle(libelleEC);
                this.listeEC.add(ec);
            }
            db.getConnection().close();
        } catch (SQLException ex) {
            Logger.getLogger(ListeEC.class.getName()).log(Level.SEVERE, null, ex);
        }
  }
}
